from scrapy.http import HtmlResponse
from scrapy.selector import Selector

body = '''
 <html>
 <body>
 <h1>Hello World</h1>
 <h1>Hello Scrapy</h1>
 <b>Hello python</b>
 <ul>
 <li>C++</li>
 <li>Java</li>
 <li>Python</li>
 </ul>
 </body>
 </html>
'''

response = HtmlResponse(url='http://www.example.com', body=body, encoding='utf8')
selector = Selector(response=response)

h1_list = selector.xpath('//h1/text()')
print(h1_list)
b_list = selector.xpath('//b')
print(b_list)

for sel in h1_list:
    # print(sel.xpath('./h1/text()'))
    print(sel.extract())

li_list = selector.xpath('//li/text()')
for li in li_list:
    print(li)
    print(li.extract())
